
public class EulerProblem7 {
    boolean isItPrime(int possiblePrimeNumber){
        for(int i=2;i<=Math.sqrt(possiblePrimeNumber);i++){
            if(possiblePrimeNumber%i ==0){
                return false;
            }
        }
        return true;
    }
    int findNthPrime(int targetPrime){
        int p=0;
//        int i=2;
        /*for( i=2;i<=nthPrime;){
          System.out.println("i:"+i);
            if(isItPrime(i)){
                System.out.println("i inside if:"+i);
                i++;
//                nthPrime++;
                System.out.println("i after ++:"+i);
            }
            else {
                System.out.println("i inside else:"+i);
            i++;
                System.out.println("i after ++:"+i);
            }
        }*/
        /*int NumPrimes = 1;
//		long i = 2;
		while(NumPrimes <= nthPrime)
		{
			if (isItPrime(i))
			{
				i++;
				NumPrimes++;
			}
			else i++;
		}
        return i;*/
        int output = 0;
		int primesFound = 3; //EulerUtil.isPrime already removes 2,3,5
//		int targetPrime = 10001;
        for (int i=7; primesFound<=targetPrime; i++){

			if (isItPrime(i)){
				primesFound++;
				if (primesFound==targetPrime){
					output = i;
				}
			}
		}
		return output;
	}

    public static void main(String []arg){
//        System.out.print(new EulerProblem7().isItPrime(2));
        System.out.println(new EulerProblem7().findNthPrime(5));
    }

}
